# coding=utf-8
#


from django.db import models

from iminer.user.models import User


class Account(models.Model):
    """ 矿工账号 """
    user = models.ForeignKey(User, verbose_name="矿工所属用户",
                             on_delete=models.SET_NULL, null=True, blank=True)
    email = models.CharField(max_length=128, verbose_name="矿工账号")
    token = models.TextField(default="", verbose_name="鉴权Token（不是挖矿Token）")
    create_time = models.DateTimeField(auto_now=False, auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="修改时间")

    class Meta:
        ordering = ("-create_time",)
        verbose_name = "矿工账号"
        verbose_name_plural = "矿工账号管理"

    def __str__(self):
        return self.email

